package com.ourteam.product.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.ui.dao.ProductUIActionGroupDAOQueryBean;
import com.ourteam.product.ui.domain.ProductUIActionGroupBean;

public class ProductUIActionGroupSearchModel extends AbstractSearchModel<ProductUIActionGroupDAOQueryBean> {

	private Long domainId;
	
	private String actionGroupCode;

	public String getActionGroupCode() {
		return actionGroupCode;
	}

	public void setActionGroupCode(String actionGroupCode) {
		this.actionGroupCode = actionGroupCode;
	}

	public Long getDomainId() {
		return domainId;
	}

	public void setDomainId(Long domainId) {
		this.domainId = domainId;
	}

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductUIActionGroupBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductUIActionGroupDAOQueryBean queryBean) throws Exception {
		ProductUIActionGroupDAOQueryBean.Criteria criteria = queryBean.createCriteria();
		if (domainId != null && domainId != 0) {
			criteria.andDomainIdEqualTo(domainId);
		}
		if(StringUtils.isNotBlank(actionGroupCode)) {
			criteria.andActionGroupCodeLike(actionGroupCode);
		}
	}

}
